

* Open log
capture log close
log using "Data analysis\cbld-description02-fig02", replace text


* ***********************************************************************************
* Fig. 2. Real-world coalition-building dynamics in the Council of the European Union
* ***********************************************************************************

* Programme:	cbld-description02-fig02.do
* Project:		Council coalition building
* Author:		Frank Haege, Department of Politics and Administration, University of Limerick
* Contact:		frank.haege@ul.ie

* Description
*************
* This do-file generates a graph of four snapshots of member state positions in 
* Council negotiations leading to the adoption of a common position on the 
* batteries directive between June and December 2004. Note that the arrows 
* indicating changes in positions between two snapshots were added manually
* in Stata's graph editor.


* Set up Stata
version 11
clear all
macro drop _all
set linesize 80
set more off

* Load member state position data from empirical case study
insheet using "Experiments\Other data\cbld-case-study-121020-stata.csv", clear

* Reshape dataset into long format (from time-issue to time-issue-country observations)
reshape long country_, i(issue round) j(country) string
rename country_ position

*Reshape dataset into wide format (from time-issue-country to time-country observations)
reshape wide position, i(round country) j(issue)


* Generate and recode variables for plotting
********************************************

* Recode and rename negotiation round variable
replace round = round - 1
rename round time

* Generate axis coordinate variables for issue dimensions
tab position1, m
recode position1 (1 = -8) (2 = -5) (3 = -2) (4 = 2) (5 = 5) (6 = 8), gen(xcor)
tab xcor, m
tab position2, m
recode position2 (0 = -8) (1 = -4) (2 = 0) (3 = 4) (4 = 8), gen(ycor)
tab ycor, m

* Drop original issue position variables
drop position1 position2

* Generate voting weight variable
generate vweight = .
replace vweight = 12 if country == "be"
replace vweight = 29 if country == "fr"
replace vweight = 29 if country == "de"
replace vweight = 29 if country == "it"
replace vweight = 13 if country == "nl"
replace vweight = 7 if country == "dk"
replace vweight = 7 if country == "ie"
replace vweight = 29 if country == "uk"
replace vweight = 12 if country == "el"
replace vweight = 12 if country == "pt"
replace vweight = 27 if country == "es"
replace vweight = 10 if country == "at"
replace vweight = 7 if country == "fi"
replace vweight = 10 if country == "se"
replace vweight = 3 if country == "cy"
replace vweight = 12 if country == "cz"
replace vweight = 4 if country == "ee"
replace vweight = 12 if country == "hu"
replace vweight = 4 if country == "lv"
replace vweight = 7 if country == "lt"
replace vweight = 3 if country == "mt"
replace vweight = 27 if country == "pl"
replace vweight = 7 if country == "sk"
replace vweight = 4 if country == "si"

* Generate weighted coalition size variable
sum time xcor ycor
egen wmycoalsize = sum(vweight), by(time xcor ycor)

* Label variables
label var xcor "Ban on Cadmium"
label var ycor "Collection Targets"
label var time "Time" 
label var country "Country"
label var vweight "Voting weight"
label var wmycoalsize "Coalition size (weighted votes)"
label var document "Number of Council source document"
label var date "Date of position snapshot"


* Plot of member state positions before Coreper meeting on 24 November
**********************************************************************

* Identify voting weight size of coalitions
tab wmycoalsize if time == 0
tab wmycoalsize if time == 0 & xcor != .

* Generate marker symbol size weights as a function of coalition size	
local 7 = 7^.5
local 10 = 10^.5
local 14 = 14^.5
local 24 = 24^.5
local 27 = 27^.5
local 29 = 29^.5
local 33 = 33^.5
local 46 = 46^.5
local 56 = 56^.5
	
* Plot member state positions 	
twoway (scatter ycor xcor if time == 0 & wmycoalsize == 56, /*
	*/ msymbol(o) msize(*`56') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 0 & wmycoalsize == 46, /*
	*/ msymbol(o) msize(*`46') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 0 & wmycoalsize == 33, /*
	*/ msymbol(o) msize(*`33') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 0 & wmycoalsize == 29, /*
	*/ msymbol(o) msize(*`29') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 0 & wmycoalsize == 27, /*
	*/ msymbol(o) msize(*`27') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 0 & wmycoalsize == 24, /*
	*/ msymbol(o) msize(*`24') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 0 & wmycoalsize == 14, /*
	*/ msymbol(o) msize(*`14') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 0 & wmycoalsize == 10, /*
	*/ msymbol(o) msize(*`10') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 0 & wmycoalsize == 7, /*
	*/ msymbol(o) msize(*`7') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 0 & wmycoalsize > 3, /*
	*/ xlabel(-10 -5:10) ylabel(-10 -5:10) /*
	*/ xscale(range(-10 10)) yscale(range(-10 10)) /*
	*/ msymbol(i) mlabel(wmycoalsize) mlabsize(small) mlabpos(center) /*
	*/ mlabcolor(white) mfcolor(gray) /*
	*/ text(6 -5 "DE", size(vsmall)) /*
	*/ text(3 -8 "FR" "PL", size(vsmall)) /*
	*/ text(-1.7 -5 "IE SK", size(vsmall)) /*
	*/ text(-4 -7.5 "CZ" "PT", size(vsmall) justification(right)) /*
	*/ text(-10 -8 "UK", size(vsmall)) /*
	*/ text(-8 -2.5 "IT" "LV", size(vsmall) justification(left)) /*
	*/ text(-4 6.7 "CY" "SI", size(vsmall) justification(left)) /*
	*/ text(0 7.5 "ES", size(vsmall)) /*
	*/ text(4 2 "AT" "BE" "EE" "FI" "NL", size(vsmall) justification(right)) /*
	*/ text(8 9.7 "DK", size(vsmall)) /*
	*/ text(4 9.8 "SE", size(vsmall)) /*
	*/ text(-9 5.5 "No position:" "EL, HU, LT, LU, MT", size(vsmall) justification(left)) /*
	*/ aspectratio(1) legend(off) subtitle("Coreper (24 Nov.)")) /*
	*/ , saving("Data analysis\Graphs\cbld-description02-fig02a.gph", replace) 


* Plot of member state positions before Coreper meeting on 1 December
*********************************************************************

* Identify voting weight size of coalitions
tab wmycoalsize if time == 1
tab wmycoalsize if time == 1 & xcor != .
	
* Generate marker symbol size weights as a function of coalition size	
local 7 = 7^.5
local 14 = 14^.5
local 17 = 17^.5
local 29 = 29^.5
local 36 = 36^.5
local 62 = 62^.5
local 100 = 100^.5
	
* Plot member state positions 	
twoway (scatter ycor xcor if time == 1 & wmycoalsize == 100, /*
	*/ msymbol(o) msize(*`100') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 1 & wmycoalsize == 62, /*
	*/ msymbol(o) msize(*`62') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 1 & wmycoalsize == 36, /*
	*/ msymbol(o) msize(*`36') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 1 & wmycoalsize == 29, /*
	*/ msymbol(o) msize(*`29') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 1 & wmycoalsize == 17, /*
	*/ msymbol(o) msize(*`17') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 1 & wmycoalsize == 14, /*
	*/ msymbol(o) msize(*`14') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 1 & wmycoalsize == 7, /*
	*/ msymbol(o) msize(*`7') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 1 & wmycoalsize > 3, /*
	*/ xlabel(-10 -5:10) ylabel(-10 -5:10) /*
	*/ xscale(range(-10 10)) yscale(range(-10 10)) /*
	*/ msymbol(i) mlabel(wmycoalsize) mlabsize(small) mlabpos(center) /*
	*/ mlabcolor(white) mfcolor(gray) /*
	*/ text(6 -5 "DE", size(vsmall)) /*
	*/ text(2 -8 "FR", size(vsmall)) /*
	*/ text(-1.7 -5 "IE SK", size(vsmall)) /*
	*/ text(-4 -7.8 "EL" "CZ" "PT", size(vsmall) justification(right)) /*
	*/ text(-8 -8.2 "IT" "LV" "UK", size(vsmall) justification(right)) /*
	*/ text(-4 6.7 "CY" "SI", size(vsmall) justification(left)) /*
	*/ text(0 9 "BE" "EE" "ES" "LT" "NL" "PL" "SE", size(vsmall) justification(left)) /*
	*/ text(8 6.5 "DK", size(vsmall)) /*
	*/ text(4 7 "AT" "FI", size(vsmall) justification(left)) /*
	*/ text(-9.5 4.5 "No position: HU, LU, MT", size(vsmall) justification(left)) /*
	*/ aspectratio(1) legend(off) subtitle("Coreper (1 Dec.)")) 	/*
	*/ , saving("Data analysis\Graphs\cbld-description02-fig02b.gph", replace) 


* Plot of member state positions before Coreper meeting on 8 December
*********************************************************************

* Identify voting weight size of coalitions
tab wmycoalsize if time == 2
tab wmycoalsize if time == 2 & xcor != .

* Generate marker symbol size weights as a function of coalition size	
local 3 = 3^.5
local 4 = 4^.5
local 7 = 7^.5
local 13 = 13^.5
local 29 = 29^.5
local 36 = 36^.5
local 43 = 43^.5
local 62 = 62^.5
local 116 = 116^.5
	
* Plot member state positions 	
twoway (scatter ycor xcor if time == 2 & wmycoalsize == 3, /*
	*/ msymbol(o) msize(*`3') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize == 116, /*
	*/ msymbol(o) msize(*`116') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize == 62, /*
	*/ msymbol(o) msize(*`62') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize == 43, /*
	*/ msymbol(o) msize(*`43') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize == 36, /*
	*/ msymbol(o) msize(*`36') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize == 29, /*
	*/ msymbol(o) msize(*`29') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize == 13, /*
	*/ msymbol(o) msize(*`13') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize == 7, /*
	*/ msymbol(o) msize(*`7') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize == 4, /*
	*/ msymbol(o) msize(*`4') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize > 3, /*
	*/ xlabel(-10 -5:10) ylabel(-10 -5:10) /*
	*/ xscale(range(-10 10)) yscale(range(-10 10)) /*
	*/ msymbol(i) mlabel(wmycoalsize) mlabsize(small) mlabpos(center) /*
	*/ mlabcolor(white) mfcolor(gray) /*
	*/ text(3.3 -5 "DE" "IE" "SK", size(vsmall)) /*
	*/ text(2 -8 "FR", size(vsmall)) /*
	*/ text(-1.8 -2 "NL", size(vsmall)) /*
	*/ text(-4 -7.8 "EL" "CZ" "PT", size(vsmall) justification(right)) /*
	*/ text(-8 -8.2 "IT" "LV" "UK", size(vsmall) justification(right)) /*
	*/ text(-4 6.5 "CY", size(vsmall)) /*
	*/ text(-4 3.3 "SI", size(vsmall)) /*
	*/ text(0 7 "AT BE" "DK EE" "ES HU" "LT PL" "SE", size(vsmall) justification(left)) /*
	*/ text(5.5 2 "FI", size(vsmall)) /*
	*/ text(-9.5 5.5 "No position: LU, MT", size(vsmall) justification(left)) /*
	*/ aspectratio(1) legend(off) subtitle("Coreper (8 Dec.)")) 	/*
	*/ , saving("Data analysis\Graphs\cbld-description02-fig02c.gph", replace) 	


* Plot of member state positions before Council meeting on 20 December
**********************************************************************

* Identify voting weight size of coalitions
tab wmycoalsize if time == 3
tab wmycoalsize if time == 3 & xcor != .
	
* Generate marker symbol size weights as a function of coalition size	
local 4 = 4^.5
local 91 = 91^.5
local 104 = 104^.5
local 117 = 117^.5

* Plot member state positions 	
twoway (scatter ycor xcor if time == 3 & wmycoalsize == 117, /*
	*/ msymbol(o) msize(*`117') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 3 & wmycoalsize == 104, /*
	*/ msymbol(o) msize(*`104') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 3 & wmycoalsize == 91, /*
	*/ msymbol(o) msize(*`91') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 2 & wmycoalsize == 4, /*
	*/ msymbol(o) msize(*`4') mcolor(white) mfcolor(gray)) /*
	*/ (scatter ycor xcor if time == 3 & wmycoalsize > 3, /*
	*/ xlabel(-10 -5:10) ylabel(-10 -5:10) /*
	*/ xscale(range(-10 10)) yscale(range(-10 10)) /*
	*/ msymbol(i) mlabel(wmycoalsize) mlabsize(small) mlabpos(center) /*
	*/ mlabcolor(white) mfcolor(gray) /*
	*/ text(4 -2 "DE FR HU" "IE NL PL", size(vsmall)) /*
	*/ text(-4 -6.5 "IT EL" "CY CZ" "LV MT" "PT UK", size(vsmall) justification(right)) /*
	*/ text(-4 3.3 "SI", size(vsmall)) /*
	*/ text(0 6.5 "AT BE" "DK EE" "ES FI" "LT SE" "SK", size(vsmall) justification(left)) /*
	*/ text(-9.5 6.5 "No position: LU", size(vsmall) justification(left)) /*
	*/ aspectratio(1) legend(off) subtitle("Council (20 Dec.)")) /*
	*/ , saving("Data analysis\Graphs\cbld-description02-fig02d.gph", replace) 


* Combine plots of member state positions at different point in time into a single graph
****************************************************************************************

* Combine plots
graph combine /*
	*/ "Data analysis\Graphs\cbld-description02-fig02a.gph" /*
	*/ "Data analysis\Graphs\cbld-description02-fig02b.gph" /*
	*/ "Data analysis\Graphs\cbld-description02-fig02c.gph" /*
	*/ "Data analysis\Graphs\cbld-description02-fig02d.gph" /*
	*/ , xsize(3) ysize(3) imargin(tiny) saving("Data analysis\Graphs\cbld-description02-fig02.gph", replace)

	
* Exit do-file
log close
exit
